package com.guandata.cdc.model.db_type.gauss;

import com.guandata.cdc.model.sink.AbstractSinkConfig;
import lombok.ToString;
import org.apache.flink.api.java.utils.ParameterTool;

@ToString
public class GaussSinkConfig extends AbstractSinkConfig {
    private static final String DEFAULT_JDBC_URL_PREFIX = "jdbc:gaussdb://%s:%d/%s";

    public final String sinkJdbcUrl;

    public final String sinkSchema;

    public final String connector = "dws";

    public GaussSinkConfig(ParameterTool parameterTool) {
        super(parameterTool);
        // 可以通过下面的SQL查看gauss db的对应schemaname
        // SELECT distinct(tablename), schemaname from pg_tables where tablename = '表名字';
        this.sinkSchema = parameterTool.getRequired("sink.schema");
        this.sinkJdbcUrl = String.format(DEFAULT_JDBC_URL_PREFIX, sinkHostName, sinkPort, sinkDatabaseName);
    }
}
